{extend name="template/base" /}
{block name="content"}

<style>
    select[multiple]+.layui-form-select>.layui-select-title>input.layui-input{ border-bottom: 0}
    select[multiple]+.layui-form-select dd{ padding:0;}
    select[multiple]+.layui-form-select .layui-form-checkbox[lay-skin=primary]{ margin:0 !important; display:block; line-height:36px !important; position:relative; padding-left:26px;}
    select[multiple]+.layui-form-select .layui-form-checkbox[lay-skin=primary] span{line-height:36px !important; float:none;}
    select[multiple]+.layui-form-select .layui-form-checkbox[lay-skin=primary] i{ position:absolute; left:10px; top:0; margin-top:9px;}
    .multiSelect{ line-height:normal; height:auto; padding:4px 10px; overflow:hidden;min-height:38px; margin-top:-38px; left:0; z-index:99;position:relative;background:none;}
    .multiSelect a{ padding:2px 5px; background:#908e8e; border-radius:2px; color:#fff; display:block; line-height:20px; height:20px; margin:2px 5px 2px 0; float:left;}
    .multiSelect a span{ float:left;}
    .multiSelect a i {float:left;display:block;margin:2px 0 0 2px;border-radius:2px;width:8px;height:8px;padding:4px;position:relative;-webkit-transition:all .3s;transition:all .3s}
    .multiSelect a i:before, .multiSelect a i:after {position:absolute;left:8px;top:2px;content:'';height:12px;width:1px;background-color:#fff}
    .multiSelect a i:before {-webkit-transform:rotate(45deg);transform:rotate(45deg)}
    .multiSelect a i:after {-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}
    .multiSelect a i:hover{ background-color:#545556;}
    .multiOption{display: inline-block; padding: 0 5px;cursor: pointer; color: #999;}
    .multiOption:hover{color: #5FB878}

    @font-face {font-family: "iconfont"; src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAaoAAsAAAAACfwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7kokY21hcAAAAYAAAABwAAABsgdU06BnbHlmAAAB8AAAAqEAAAOUTgbbS2hlYWQAAASUAAAALwAAADYR+R9jaGhlYQAABMQAAAAcAAAAJAfeA4ZobXR4AAAE4AAAABMAAAAUE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VMML6SGHozx8Od3ZvCEvlm5KQ0nxPTJtiLHD7ny1jsnxYsAF7imkq8QVEOBgF5Yh0yNkpPIenN2QAsSdMNX6xu85VC/tiE3Mat6P8JqWM73NLhZ9mzjBy5uAlAlJYBiMRDPQleQ+9FEFfJJImGnHQHWIEmm/5UB8h8uaIIzrc4SEPozByel3oDvFcN+4D+dU/uou/L2xv/1mUQBdTCIN+jGUEgV47UkB+Aw7YpAMAAAB4nGNgZGBgAGLbQwYd8fw2Xxm4WRhA4HrO20sI+n8DCwOzE5DLwcAEEgUAPX4LPgB4nGNgZGBgbvjfwBDDwgACQJKRARWwAgBHCwJueJxjYWBgYH7JwMDCgMAADpsA/QAAAAAAAHYA/AGIAcp4nGNgZGBgYGWIYWBjAAEmIOYCQgaG/2A+AwASVwF+AHicZY9NTsMwEIVf+gekEqqoYIfkBWIBKP0Rq25YVGr3XXTfpk6bKokjx63UA3AejsAJOALcgDvwSCebNpbH37x5Y08A3OAHHo7fLfeRPVwyO3INF7gXrlN/EG6QX4SbaONVuEX9TdjHM6bCbXRheYPXuGL2hHdhDx18CNdwjU/hOvUv4Qb5W7iJO/wKt9Dx6sI+5l5XuI1HL/bHVi+cXqnlQcWhySKTOb+CmV7vkoWt0uqca1vEJlODoF9JU51pW91T7NdD5yIVWZOqCas6SYzKrdnq0AUb5/JRrxeJHoQm5Vhj/rbGAo5xBYUlDowxQhhkiMro6DtVZvSvsUPCXntWPc3ndFsU1P9zhQEC9M9cU7qy0nk6T4E9XxtSdXQrbsuelDSRXs1JErJCXta2VELqATZlV44RelzRiT8oZ0j/AAlabsgAAAB4nGNgYoAALgbsgJWRiZGZkYWRlZGNgbGCuzw1MykzMb8kU1eXs7A0Ma8CiA05CjPz0rPz89IZGADc3QvXAAAA') format('woff')}
    .iconfont {font-family:"iconfont" !important;font-size:16px;font-style:normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
    .icon-fanxuan:before { content: "\e837"; }
    .icon-quanxuan:before { content: "\e623"; }
    .icon-qingkong:before { content: "\e63e"; }
</style>
<link rel="stylesheet" href="/static/admin/layui-xia/css/layui.css" media="all"/>
<link rel="stylesheet" href="/static/admin/formSelects/dist/formSelects-v4.css">
<div class="page-container">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>
    <form class="layui-form" action="/admin/notify/add" method="post">
        <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" placeholder="请输入标题" autocomplete="off" name="title" class="layui-input" value="{$vo.title ?? ''}" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否阅读</label>
            <div class="layui-input-block">
                <select name="isread" lay-verify="" disabled>
                    <option value="0">请选择是否已阅读</option>
                    <option value="1">是</option>
                    <option value="0">不是</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">阅读时间</label>
            <div class="layui-input-block">
                <input type="text" placeholder="请输入阅读时间" autocomplete="off" class="layui-input" name="read_time" readonly value="{$vo.read_time ?? ''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <textarea name="content" placeholder="请输入内容" class="layui-textarea">{$vo.content ?? ''}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">消息类型</label>
            <div class="layui-input-block">
                <select name="type" lay-verify="" lay-search>
                    <option value="system_ordinary_info">系统普通消息</option>
                    {foreach $type as $type}
                    <option value="{$type.value}">{$type.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">用户</label>-->
<!--            <div class="layui-input-block"  style="height: 100px">-->
<!--                <select name="user_id" id="searchDriver" xm-select="search05" xm-select-search-type="dl" xm-select-search="{$url}" style="height: 100px;overflow: auto">-->
<!--                    <option value="">请选择要发送的司机</option>-->
<!--                </select>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item">
            <label class="layui-form-label">用户</label>
            <div class="layui-input-block"  style="height: 180px">
                <textarea name="user_id" id="user_id" placeholder="请输入内容" class="layui-textarea" style="width: 60%;height: 150px;">
                </textarea>
                <br>
                <button type="button" class="layui-btn" onclick="addDriver()"><i class="layui-icon">&#xe608;</i>选择司机</button>
            </div>
        </div>
        <input type="text" hidden name="userIds" id="userIds">
        <br><br>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">发送信息</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="/static/admin/layui-xia/layui.js"></script>
<script type="text/javascript" src="/static/admin/formSelects/src/formSelects-v4.js"></script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<style>
    .xm-select-parent .xm-select {
        line-height: normal;
        height: 100px;
        min-height: 36px;
        left: 0px;
        z-index: 99;
        position: absolute;
        padding: 4px 20px 1px 10px;
        overflow: auto;
        background: 0px 0px;
    }
</style>
<script>
    $('#searchDriver').addClass('bian');

</script>
<script>
    layui.use(['form'],function () {
        var form = layui.form,
            $ = layui.$;
        form.on('submit(formDemo)',function (data) {
            console.log('data',data)

            //使用ajax提交数据
            $.ajax({
                type: 'post',
                url: '/admin/notify/add',
                data: data.field,
                success: function (res) {
                    console.log('res', res);
                    if (res.msg){
                        layer.msg(res.msg)
                    } else{
                        layer.msg('非法操作')
                    }
                    if (!res.code){
                        layer.msg(res.msg);
                        window.parent.location.reload() // 添加成功，关闭
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index)
                    }else if(res.code == 1){
                        // parent.layer.msg(res.msg);
                        setTimeout('closePage()', 1000);

                    }
                }
            });
            return false
        })

    });
    function closePage(){
        window.parent.location.reload() // 添加成功，关闭
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index)
    }
    $(function () {

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                ajax_progress(ret);
            }
        });
    })
</script>

<script>
    var formSelects = layui.formSelects;
    formSelects.config('search05', {
        searchUrl: "<?php echo $url; ?>",
        beforeSearch: function(id, url, val){
            if(!val){
                console.log('内容为空, 不进行远程搜索')
                return false;
            }
            return true;
        }
    });
</script>

<script>
    function addDriver() {
        console.log('选择司机');
        // 获取文本域的值
        var text = $('#user_id').val();
        layer.open({
            type: 2,
            title: '选择司机',
            area: ['90%','70%'],
            fixed: false, // 不固定
            maxmin: true,
            content: '/admin/notify/addDriver?user_info=' + text,
            // btn:['我已选好','取消'],
            yes: function (ret, index) {
                var openPage = window[index.find('iframe')[0]['name']]; // 获得弹出页面
                var val = openPage.submitDriver()
                if (val == null){
                    layer.msg('您没有选择任何发货单',{icon:5});
                }else{
                    layer.msg(value);
                }
            }
        });
    }
</script>

{/block}
